<?php
namespace app;

use Workerman\Worker;
use Workerman\Mqtt\Client;
require_once __DIR__ . '/vendor/autoload.php';

$worker = new Worker();
//$mqtt = new Workerman\Mqtt\Client('mqtt://0.0.0.0:1883');
$worker->onWorkerStart = function(){
    $mqtt = new Workerman\Mqtt\Client('mqtt://0.0.0.0:1883');
    $mqtt->onConnect = function($mqtt) {
        $mqtt->publish('test', 'hello workerman mqtt');
    };
    $mqtt->connect();
};


//$mqtt->connect();
Worker::runAll();